package com.crl.utils.color
{
	import flash.display.GradientType;
	import flash.display.Graphics;
	import flash.geom.Matrix;
	
	
	/**
	 *  饱和度与亮度 混合调节器;
	 * @author crl
	 * 
	 */	
	public class SaturationMixer extends AbstractMixer
	{
		
		private var brightnessColors:Array=[0,0];
		
		public function SaturationMixer()
		{
		}
		
		override protected function defaults():void{
			colors=[0xFFFFFF,0xFFFFFF];
			alphas=[0,100];
			ratios=[0,0xFF];
		}
		
		
		/**
		 * 设置些参数,其实只用色像来做处理. 
		 * @param value
		 * 
		 */		
//		public function set hsb(value:HSB):void{
//			this._hsb=value.clone();
//			
//			this._color=ConvertColor.RGBToHex(ConvertColor.HSBToRGB(this._hsb));
//			
//			invalidate();
//		}
//		
//		public function get hsb():HSB{
//			return this._hsb;
//		}
		
		
		override public function render() : void{
			
			var g:Graphics=this.graphics;
			g.clear();
			
			g.beginFill(_color);
			g.drawRect(0,0,w,h);
			g.endFill();
			
			
			g=mark.graphics;
			g.clear();
			
			var matrix:Matrix=new Matrix();
			matrix.createGradientBox(w,h,Math.PI);
			
			
			g.beginGradientFill(GradientType.LINEAR,colors,alphas,ratios,matrix);
			g.drawRect(0,0,w,h);
			g.endFill();
			
			matrix.createGradientBox(w,h,Math.PI*.5);
			g.beginGradientFill(GradientType.LINEAR,brightnessColors,alphas,ratios,matrix);
			g.drawRect(0,0,w,h);
			g.endFill();
			
			
//			this.pointer.x=_hsb.s/100*w;
//			this.pointer.y=h-_hsb.b/100*h
			
		}
	}
}